home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.std.c,com[p.lang.std.c++
- Subject: Re: preprocessing question
- Date: 05 Mar 1996 14:40:05 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar5074005@qcd.lanl.gov>
- References: <313b9e9f.480978@NEWS.CLOUD9.NET>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: jalvo@cloud9.net's message of Tue, 05 Mar 1996 02:07:10 GMT
-
- In article <313b9e9f.480978@NEWS.CLOUD9.NET>
- jalvo@cloud9.net (John G. Alvord) writes:
-
- <snip>
- JGA: #define XXX (1)
- JGA: #include <stdio.h>
- JGA: int main(void)
- JGA: {
- JGA: #if XXX
- JGA: printf("Hello World!");
- JGA: #endif
- JGA: return 0;
- JGA: }
- <snip>
- JGA: One compiler (SAS/C 5.50 cross compiler on AIX for MVS) complains
- that the #if
- JGA: line is an illegal constant. A close reading of the ANSI C
- standard document
- JGA: reveals a clause that seems to imply (my reading) that a
- pre-processed series
- JGA: of tokens that appear to be a preprocessing statement will be ignored. A
- JGA: coworker who is more experienced then me feels that the #if does not fall
- JGA: under that clause and the #if will be evaluated. His reasoning is that the
- JGA: preprocessed series of tokens is just a part of a preprocessing statement.
-
- Don't read that close!
-
- A line that begins with a # optionally preceded by whitespace is
- recognized as a preprocessing directive, and macro expansions are
- prohibited within it, except by special dispensation. The argument of
- #if has such special dispensation: but note that this preprocessing is
- done as a part of processing a pp-directive.
-
- The statement in the standard is to prevent you from doing
-
- #define X #if XXX
- #define Y #endif
-
- and then writing
-
- X
- printf("Hello World!\n");
- Y
-
- In any case (1) is a completely valid constant, so I have no idea what
- your compiler is complaining about. Does it compile `#if (1)'
- properly, or does it want `#if 1' instead?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-